-
Notifications
You must be signed in to change notification settings - Fork 122
staticaddr: fast-flag #1009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
staticaddr: fast-flag #1009
Conversation
Summary of ChangesHello @hieblmi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the static address loop-in functionality by introducing a 'fast' option. This feature allows users to prioritize the speed of on-chain transaction publishing for fractional change amounts, enabling quicker access to funds by bypassing standard batching delays. The implementation involves comprehensive updates across the system, from the command-line interface and API definitions to the database schema and the sweep batching mechanism, ensuring that the 'fast' preference is consistently handled and applied. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a --fast
flag for static address loop-in swaps, enabling expedited publishing of the on-chain transaction in exchange for a potentially higher fee. The implementation correctly propagates this flag from the CLI and RPC layers down to the server request, and the database schema is updated accordingly. The main feature appears to be well-implemented.
Additionally, a similar fast
flag mechanism has been added to the sweepbatcher
for client-side sweeps. However, this functionality seems to be unused in the current changes, which could lead to confusion. I've added a review comment to seek clarification on this part of the implementation.
|
||
/* | ||
If set to true the server will immediately publish the swap in exchange for | ||
a higher fee. This can be useful if the client expects change from a swap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only available for swaps with change...
swapserverrpc/server.proto
Outdated
// has to pay when the sweeping transaction is broadcast. | ||
uint32 num_static_address_deposits = 7; | ||
|
||
// If set, request the server to use fast publication behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
407d912
to
d5567e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🌴
Great work!
I left few proposals. The most important one is in sweepbatcher to let fast swaps batching. I proposed a way how to do it keeping the change small.
bool auto_select_deposits = 10; | ||
|
||
/* | ||
If set to true the server will immediately publish the swap in exchange for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a note that this field is only allowed for static loop-ins. If it is used in a regular loop-in, loopd
should return an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
swapserverrpc/server.proto
Outdated
// has to pay when the sweeping transaction is broadcast. | ||
uint32 num_static_address_deposits = 7; | ||
|
||
// If set, request the server to use fast publication behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a note that this field is only allowed for static loop-ins. If it is used in a regular loop-in, loop server is expected to return an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,2 @@ | |||
-- Drop 'fast' flag from static_address_swaps | |||
ALTER TABLE static_address_swaps DROP COLUMN fast; No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line end is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -0,0 +1,2 @@ | |||
-- Add 'fast' flag to static_address_swaps, default false | |||
ALTER TABLE static_address_swaps ADD COLUMN fast BOOLEAN NOT NULL DEFAULT false; No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line end is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
// logged as a warning. | ||
type InitialDelayProvider func(ctx context.Context, numSweeps int, | ||
value btcutil.Amount) (time.Duration, error) | ||
value btcutil.Amount, fast bool) (time.Duration, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, true
is never passed to this callback. If fast=true
, there is a separate code path in spinUpBatch
:
if cfg.initialDelayProvider == nil || fast {
cfg.initialDelayProvider = zeroInitialDelay
}
I propose to use this new argument instead of making a special case in spinUpBatch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast=true
is passed on the delay provider on the server side.
// If fast is set, we spin up a new batch which is published | ||
// immediately. | ||
if fast { | ||
return b.spinUpNewBatch(ctx, sweeps, true) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents batching fast sweeps. It makes sense to batch them to save on fees.
I propose to remove this if
and track fastness per sweep
. We can add the flag to sweep
and modify batch.Run
method to pass fast
to b.cfg.initialDelayProvider
call (the only place where initialDelayProvider
is called).
It makes sense to add method isFast()
for batch similar to isUrgent
and call if from batch.Run
for convenience.
And we don't need to pass fast
to spinUpBatch
anymore, because we can always deduce it from sweeps
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion to briefly delay the publication of a fast batch to gather more fast swaps. This will be addressed in a separate PR.
Private: req.Private, | ||
Initiator: defaultLoopdInitiator, | ||
NumDeposits: uint32(numDeposits), | ||
Fast: req.Fast, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to check here that if req.Fast
is set, we make sure that the swap is static. Otherwise fail. Just as a sanity check measure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a sanity check.
Usage: "expedited publishing of the change output if " + | ||
"the swap creates one. This results in a " + | ||
"higher swap fee.", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to rephrase it to make the purpose clearer:
Usage: "complete the swap faster by paying a higher fee, so the change output is available sooner",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this description
"swapped from the selected deposits. If there" + | ||
"is change it is sent back to the static " + | ||
"address.", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep previous flag as well? So it is possible to set it via --amount
. Some people may prefer this, e.g. in scripts where each argument is on a separate line. Positional argument is good for manual use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, I re-added the flag.
CLI is broken:
Also:
I think this also exists in It seems to pass |
Yes thanks, I noticed this bug a while ago and have a fix on my todo list. Its because the quoting part doesn't have access to the utxo amount yet. |
…cAddressLoopInRequest
--fast allows the client to expedite the publishing of on-chain swap transactions with change, e.g. if --amount was specified.
The fast flag enables the client to access change of a fractional amount swap faster. Since batching can delay the publishing of the on-chain swap transaction the client can pay a fee for faster access to optional change. A few examples of how this PR changes the command line arguments for fractional swaps.